package com.ztesoft.web.taskgenerator.db.dao.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds;

import com.ztesoft.web.taskgenerator.db.arg.DmTaskStageArg;
import com.ztesoft.web.taskgenerator.db.po.DmTaskStagePO;

public interface IDmTaskStageMapper {
	List<Integer> countByArg(DmTaskStageArg arg);

	int deleteByArg(DmTaskStageArg arg);

	List<DmTaskStagePO> selectByArg(DmTaskStageArg arg);

	List<DmTaskStagePO> getCheckObjNameByTaskId(Integer dmTaskId);
	
	/**
	 * 根据任务id提取任务环节表清理环节记录 只取“数据恢复中”、“处理完成”或“失败”的清理环节记录
	 * 
	 * @param dmTaskId
	 * @return
	 */
	List<DmTaskStagePO> selectForDataRecovery(Integer dmTaskId);

	int updateByArgSelective(@Param("record") DmTaskStagePO record, @Param("arg") DmTaskStageArg arg);

	int updateByArg(@Param("record") DmTaskStagePO record, @Param("arg") DmTaskStageArg arg);

	List<DmTaskStagePO> selectByArgAndPage(DmTaskStageArg arg, RowBounds rowBound);

	int insert(DmTaskStagePO record);

	int insertSelective(DmTaskStagePO record);

	int insertBatch(@Param("list") List<DmTaskStagePO> records);

	int deleteByPrimaryKey(Integer id);

	DmTaskStagePO selectByPrimaryKey(Integer id);

	int updateByPrimaryKeySelective(DmTaskStagePO record);

	int updateByPrimaryKey(DmTaskStagePO record);

	List<DmTaskStagePO> selectByTaskId(Integer dmTaskId);

	int updateByIdAndStage(DmTaskStagePO record);

	int updateStageByDelayPause(Integer dmPlanId);

	List<DmTaskStagePO> selectStageAndStrategy(Integer dmTaskId);

	List<DmTaskStagePO> selectStage(@Param("dmStrategyId") Integer dmStrategyId, @Param("dmTaskId") Integer dmTaskId);

	List<DmTaskStagePO> selectListByArgAndPage(DmTaskStageArg arg, RowBounds rowBound);

	List<DmTaskStagePO> selectAllListByArgAndPage(DmTaskStageArg arg, RowBounds rowBound);

	List<DmTaskStagePO> selectListInfo(@Param("dmTaskId") Integer dmTaskId, @Param("state") String state,
			RowBounds rowBound);

	DmTaskStagePO selectBySourceDataId(@Param("sourceDataId") Integer sourceDataId);
	
	DmTaskStagePO selectStateCount(@Param("dmTaskId") Integer dmTaskId);

	List<DmTaskStagePO> selectCurrentState(@Param("dmTaskId") Integer dmTaskId, @Param("state") String state);

	List<DmTaskStagePO> selectNextStrategy(@Param("dmTaskId") Integer dmTaskId, @Param("state") String state,
			@Param("dmStrategyId") Integer dmStrategyId);
	
	List<DmTaskStagePO> selectCurrentMultiState(@Param("dmTaskId") int dmTaskId, @Param("stateArr") String[] taskIdArr);

	int updateStateAndStartTimeByPrimaryKey(@Param("dmInfoId")Integer dmInfoId);

	int updateStateAndEndTimeByPrimaryKey(@Param("dmInfoId")Integer dmInfoId,@Param("backUpState") String backUpState);

	/*
	 * List<DmTaskStagePO> selectListByArgAndPage(
	 * 
	 * @Param("nodeId")Integer nodeId,
	 * 
	 * @Param("planName")String planName,
	 * 
	 * @Param("stage")Integer stage,
	 * 
	 * @Param("taskState")String taskState);
	 */
}